import { createRouter, createWebHistory } from "vue-router"

// 正确导入组件（注意变量名与导入路径）
import dl from '../views/login/dl.vue'
import Layout from '../views/layout/Layout.vue'

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: dl // 直接使用导入的组件对象
  },
     //   首页模块
  {
    path: '/layout',
    component: Layout, // 直接使用导入的组件对象
    meta:{
        title:'首页',
        unShow:true,
    },
    redirect: '/home',
     children:[{
       path: '/home',
       meta:{
        title:'首页',
      
    },
         //路由懒加载 
                // 只有访问这个路由时 ，才导入|运行对应的组件
                // 项目逇第一个页面需要 提升加载速度，懒加载必须处理 
                // 如果需要当页面需要提升访问速度，不能做懒加载
       component: () => import('@/views/home/Home.vue') // 懒加载直接使用导入的组件对象
     }
    ]
  },
      //   账号模块
      {
        path: '/account',
        component: Layout,
        redirect: '/accountList',
        meta:{
            title:'账号管理',
          
        },
        children: [
            {
                path: '/accountList',
                meta:{
                
                    title:'账号列表',
                },
                component: () => import('../views/account/List.vue')
            },
            {
                path: '/accountAdd',
                meta:{
                    title:'添加账号',
                },
                component: () => import('../views/account/Add.vue')
            },
            {
                path: '/accountCenter',
                meta:{
                    title:'个人中心',
                },
                component: () => import('../views/account/Center.vue')
            },
            {
                path: '/accountEdit',
                meta:{
                    title:'编辑账号',
                },
                component: () => import('../views/account/Edit.vue')
            },

        ]
    },
    //   商品模块
    {
        path: '/goods',
        component: Layout,
        redirect: '/goodsList',
        meta:{
            title:'商品管理',
        },
        children: [
            {
                path: '/goodsList',
                meta:{
                    title:'商品列表',
                },
                component: () => import('../views/goods/List.vue')
            },
            {
                path: '/goodsAdd',
                meta:{
                    title:'添加商品',
                },
                component: () => import('../views/goods/Add.vue')
            },
            {
                path: '/goodsType',
                meta:{
                    title:'商品分类',
                },
                component: () => import('../views/goods/Type.vue')
            },


        ]
    },
    //   订单模块
    {
        path: '/order',
        component: Layout,
        redirect: '/orderList',
        meta:{
            title:'订单管理',
            unShow:false,
        },
        children: [
            {
                path: '/orderList',
                meta:{
                    title:'订单列表',
                },
                component: () => import('../views/order/Order.vue')
            },
        ]
    },
    //   店铺模块
    {
        path: '/shop',
        component: Layout,
        redirect: '/shopInfo',
        meta:{
            title:'店铺管理',
        },
        children: [
            {
                path: '/shopInfo',
                meta:{
                    title:'店铺管理',
                },
                component: () => import('../views/shop/Shop.vue')
            },
        ]
    },
    //   统计模块
    {
        path: '/statistics',
        component: Layout,
        redirect: '/statisticsGoods',
        meta:{
            title:' 统计管理',
        },
        children: [
            {
                path: '/statisticsGoods',
                meta:{
                    title:'商品统计',
                },
                component: () => import('../views/statistics/Goods.vue')
            },
            {
                path: '/statisticsOrder',
                meta:{
                    title:'订单统计',
                },
                component: () => import('../views/statistics/Order.vue')
            }

        ]
    },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})
export const getMenus=() =>{
    const routes1 = JSON.parse(JSON.stringify(routes))
}
export default router